/**
 * Copyright (C) 2010 Cloudfarming <info@cloudfarming.nl>
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.cloudfarming.client.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * @author I. de Vries
 */
@NamedQueries(value = {
    @NamedQuery(name = SensorRun.Q_FIND_ALL_RUNS, query = "select r from SensorRun r")
})
@Entity
@Table(name = "SENSOR_RUN")
public class SensorRun implements Serializable, Persistable {

    public static final String Q_FIND_ALL_RUNS = "findAllRuns";

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    private long id;

    @ManyToOne(targetEntity=SensorDataFile.class)
    @JoinColumn(name = "SENSOR_DATA_FILE_ID")
    private SensorDataFile<?> sensorDataFile;
    
    @ManyToOne(targetEntity=Field.class)
    @JoinColumn(name = "PLOT_ID")
    private Field field;

    protected SensorRun() {
    }

    public SensorRun(SensorDataFile<?> sensorDataFile, Field field) {
        this.sensorDataFile = sensorDataFile;
        this.field = field;
    }

    public long getId() {
        return id;
    }

    public SensorDataFile<?> getSensorDataFile() {
        return sensorDataFile;
    }

    public void setGeoSensorDataFileBO(SensorDataFile<?> sensorDataFile) {
        this.sensorDataFile = sensorDataFile;
    }

    public Field getField() {
        return field;
    }

    public void setField(Field field) {
        this.field = field;
    }
}
